<?php  if( !defined('BASEPATH')) exit('No direct script access allowed');

if (!function_exists('html_options')) {

    /**
     * html_select list using a 2D array
     *
     * @param array $options_
     * @param string $keyValue_
     * @param array $group_
     * @param string $keyOutput_
     * @param string $selected_
     * @param bool $useKeys_
     * @return string
     */
    function html_options($options_, $keyValue_, $group_, $keyOutput_, $selected_ = null, $useKeys_ = true) { //original code has no $group
        $tOptions = "";

        if (!is_array($options_))
            return null;

        if ($useKeys_) {
            foreach ($options_ as $key => $value) {
                $selected = ($selected_ == $key) ? "selected='true'" : "";
                $tOptions .= "<option value='$key' $selected>$value[$keyOutput_]</option>";
            }
        } else {
            foreach ($options_ as $value) {
                $selected = ($selected_ == $value[$keyValue_]) ? "selected='true'" : "";
                $tOptions .= "<option value='$value[$keyValue_]'  $selected>$value[$keyOutput_]</option>";
            }
        }
        return $tOptions;
    }

}
?>
